{yun:}include file="$wapstyle/member/theader.htm"{/yun}
<link rel="stylesheet" href="{yun:}$config.sy_weburl{/yun}/app/template/wap/css/yun_wap_member.css?v={yun:}$config.cachecode{/yun}" type="text/css" />
<link rel="stylesheet" href="{yun:}$wap_style{/yun}/js/mui/css/mui.picker.min.css?v={yun:}$config.cachecode{/yun}" type="text/css" />
<link rel="stylesheet" href="{yun:}$wap_style{/yun}/js/mui/css/mui.poppicker.css?v={yun:}$config.cachecode{/yun}" type="text/css" />
<link rel="stylesheet" href="{yun:}$config.sy_weburl{/yun}/app/template/wap/css/style.css?v={yun:}$config.cachecode{/yun}" type="text/css" />
<link rel="stylesheet" href="{yun:}$wap_style{/yun}/js/umeditor/themes/default/css/umeditor.min.css?v={yun:}$config.cachecode{/yun}" type="text/css" />
<script src="{yun:}$wap_style{/yun}/js/compress.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>

<div id="app" class="mui-views">
    <div class="mui-view">
        <div class="mui-pages"></div>
    </div>
</div>


<div id="main" class="mui-page">
    
    <div class="mui-page-content">
        <div class="mui-scroll-wrapper">
            <div class="mui-scroll">
                <ul class="yunset_list mt15">
                    <li class="yunset_list_text"><span class="yunset_list_name">课程名称 </span><span class="yunset_list_commentary"> 
					<input type="text" name="name" id='name' value="{yun:}$row.name{/yun}" placeholder="请填写课程名称" >
					</span>
                    </li>
                    <li class="yunset_list_select"><span class="yunset_list_name">课程分类</span><span class="yunset_list_commentary">
					<button id='nidPicker' class="mui-btn mui-btn-block" type='button' data-nid="{yun:}$row.nid{/yun}" data-tnid="{yun:}$row.tnid{/yun}" >{yun:}if $row.nid{/yun}{yun:}$subject_name[$row.tnid]{/yun}{yun:}else{/yun}请选择课程分类{yun:}/if{/yun}</button>
					<input type="hidden" id="nid" name="nid" value="{yun:}$row.nid{/yun}">
					<input type="hidden" id="tnid" name="tnid" value="{yun:}$row.tnid{/yun}">
					</span></li>

                    <li class="yunset_list_select"><span class="yunset_list_name">培训地点</span><span class="yunset_list_commentary">
					<button id='cityPicker' class="mui-btn mui-btn-block" type='button' data-provinceid="{yun:}$row.provinceid{/yun}" data-cityid="{yun:}$row.cityid{/yun}" data-three_cityid="{yun:}$row.threecityid{/yun}">{yun:}if $row.provinceid{/yun}{yun:}$city_name[$row.provinceid]{/yun} {yun:}$city_name[$row.cityid]{/yun} {yun:}$city_name[$row.threecityid]{/yun}{yun:}else{/yun}请选择培训地点{yun:}/if{/yun}</button>
					<input type="hidden" id="provinceid" name="provinceid" value="{yun:}$row.provinceid{/yun}">
					<input type="hidden" id="cityid" name="cityid" value="{yun:}$row.cityid{/yun}">
					<input type="hidden" id="three_cityid" name="threecityid" value="{yun:}$row.threecityid{/yun}">
					</span></li>
                    <li class="yunset_list_text"><span class="yunset_list_name">培训地址</span>
                        <span class="yunset_list_commentary"> 
					<input type="text" name="address" id='address' value="{yun:}$row.address{/yun}" placeholder="请填写培训地址" >
					</span>
                    </li>
                    <li class="yunset_list_text"><span class="yunset_list_name">培训课时</span>
                        <span class="yunset_list_commentary"> 
					<input type="text" name="hours" id='hours' value="{yun:}$row.hours{/yun}" placeholder="请填写培训课时" >
					</span>
                    </li>
                    <li class="yunset_list_text"><span class="yunset_list_name">培训费用</span>
                        <span class="yunset_list_commentary"> 
					<input type="number" name="price" id='price' value="{yun:}$row.price{/yun}" placeholder="请填写培训费用" >
					</span>
                    </li>
                    <li class="yunset_list_select"><span class="yunset_list_name">收费方式</span><span class="yunset_list_commentary">
					<button id='ispricePicker' class="mui-btn mui-btn-block" type='button' data-isprice="{yun:}$row.isprice{/yun}">{yun:}if $row.isprice==1{/yun}在线收费{yun:}elseif $row.isprice==2{/yun}到场收费{yun:}else{/yun}请选择收费方式{yun:}/if{/yun}</button>
					<input type="hidden" id="isprice" name="isprice" value="{yun:}$row.isprice{/yun}">
					</span></li>
                    <li class="yunset_list_text"><span class="yunset_list_name">报名电话</span>
                        <span class="yunset_list_commentary"> 
					<input type="text" name="moblie" id='moblie' value="{yun:}$row.moblie{/yun}" placeholder="请填写报名电话" >
					</span>
                    </li>

                </ul>
                <ul class="yunset_list mt15">
                    <li>
                        <a href="#crowdhtml" id="crowdeditor" class="">
                            <span class="yunset_list_name">适合人群</span>
                            <span class="yunset_list_commentary yunset_list_js" id="crowdshow">
                        		{yun:}if $row.crowd{/yun}{yun:}$row.crowd{/yun}{yun:}else{/yun}请输入适合人群{yun:}/if{/yun}
                        	</span>
                        </a>
                    </li>
                    <li>
                        <a href="#superiorityhtml" id="superiorityeditor" class="">
                            <span class="yunset_list_name">课程优势<em class="yunset_xttip">(选填)</em></span>
                            <span class="yunset_list_commentary yunset_list_js" id="superiorityshow">
                        		{yun:}if $row.superiority{/yun}{yun:}$row.superiority{/yun}{yun:}else{/yun}请输入课程优势{yun:}/if{/yun}
                        	</span>
                        </a>
                    </li>
                    <li>
                        <a href="#contenthtml" id="contenteditor" class="">
                            <span class="yunset_list_name">课程介绍</span>
                            <span class="yunset_list_commentary yunset_list_js" id="contentshow">
                        		{yun:}if $row.content_tags{/yun}{yun:}$row.content_tags{/yun}{yun:}else{/yun}请输入课程介绍{yun:}/if{/yun}
                        	</span>
                        </a>
                        <textarea style="display:none" id="content">{yun:}$row.content{/yun}</textarea>
                    </li>

                    <li>
                        <a href="#typehtml"><span class="yunset_list_name">开课类型</span><span class="yunset_list_commentary yunset_list_js" id="typeshow">
							{yun:}if $row.typeid{/yun}
								{yun:}foreach item=v key=key from=$subject_type_index{/yun}
									{yun:}if in_array($v,$row.typeid){/yun}
										{yun:}if ($v!=$row.typeid[0]){/yun}
											,{yun:}$subject_type_name[$v]{/yun}
										{yun:}else{/yun}
											{yun:}$subject_type_name[$v]{/yun}
										{yun:}/if{/yun}
									{yun:}/if{/yun}
								{yun:}/foreach{/yun}
							{yun:}else{/yun}
							请选择开课类型
							{yun:}/if{/yun}
						</span></a>
                        <input type="hidden" id="type" name="type" value="{yun:}$row.type{/yun}">
                    </li>

                    <li>
                        <a href="#teachhtml">
                            <span class="yunset_list_name">培训讲师<em class="yunset_xttip">(选填)</em></span>
                            <span class="yunset_list_commentary yunset_list_js" id="teachshow">
							{yun:}if $row.teach{/yun}
								{yun:}foreach item=v key=key from=$teachinfo{/yun}
									{yun:}if in_array($v.id,$row.teach){/yun}
										{yun:}if ($v!=$row.teach[0]){/yun}
											{yun:}$v.name{/yun}
										{yun:}else{/yun}
											{yun:}$v.name{/yun}
										{yun:}/if{/yun}
									{yun:}/if{/yun}
								{yun:}/foreach{/yun}
							{yun:}else{/yun}
								请选择培训讲师
							{yun:}/if{/yun}
							</span>
                        </a>
                        <input type="hidden" id="teach" name="teach" value="{yun:}$row.teachid{/yun}">
                    </li>

                </ul>
                <ul class="yunset_list">
                    <li class="yunset_list_max">
                        <span class="yunset_list_name">缩略图<em class="yunset_xttip">(选填)</em></span>
                        <span class="yunset_list_tx " id="previewshow"><img id="previewimg" src="{yun:}$row.pic{/yun}"  style="border-radius:0px;border:none;"></span>
                      <div class="yunset_list_file">  <input type="file" id="pic" name="pic" onchange="previewImage(this,'preview')" accept="image/*" />
                        <input type='hidden' name='preview' value='' id='preview'></div>
                    </li>
                </ul>

                <div class="yunset_bth_box">
                    <button id="infosubmit" type="button" class="mui-btn mui-btn-block mui-btn-primary">保 存</button>
                    <input type="hidden" name="id" id="id" value="{yun:}$row.id{/yun}" />
                </div>
            </div>
        </div>
    </div>
    
</div>

<div id="crowdhtml" class="mui-page">
    <div class="mui-page-content">
        <div class="mui-scroll-wrapper">
            <div class="mui-scroll">
                <div class="yun_wap_info_brief">
                    <div class="yun_wap_info_brief_c">
                        <div class="yun_wap_addresume_box_nexttit"> 适合人群 </div>
                        <textarea class="textAreaMsg tip" id="crowd" placeholder="请输入适合人群500字以内">{yun:}$row.crowd{/yun}</textarea>
                    </div>
                    <a class="yun_wap_info_brief_tit_bc mui-action-back">确定</a>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="superiorityhtml" class="mui-page">
    <div class="mui-page-content">
        <div class="mui-scroll-wrapper">
            <div class="mui-scroll">
                <div class="yun_wap_info_brief">
                    <div class="yun_wap_info_brief_c">
                        <div class="yun_wap_addresume_box_nexttit"> 课程优势 </div>
                        <textarea class="textAreaMsg tip" id="superiority" placeholder="请输入课程优势500字以内">{yun:}$row.superiority{/yun}</textarea>
                    </div>
                    <a class="yun_wap_info_brief_tit_bc mui-action-back">确定</a>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="contenthtml" class="mui-page">
    <div class="mui-page-content">
        <div class="mui-scroll-wrapper">
            <div class="mui-scroll">
                <div class="yun_wap_info_brief">
                    <div class="yun_wap_info_brief_c">
                        <div class="yun_wap_addresume_box_nexttit"> 课程介绍 </div>
                        <textarea class="textAreaMsg tip" id="contenttext" placeholder="请输入课程介绍500字以内">{yun:}$row.content{/yun}</textarea>
                    </div>
                    <a class="yun_wap_info_brief_tit_bc mui-action-back">确定</a>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="typehtml" class="mui-page">
    <div class="mui-page-content">
        <div class="mui-scroll-wrapper">
            <div class="mui-scroll">
                <div class="yun_info_fl">
                    <div class="yun_info_fl_c">
                        <div class="yun_wap_addresume_box_nexttit">开课类型</div>
                        {yun:}foreach item=v from=$subject_type_index{/yun}
                        <div class="yun_info_fl_list">
                            <div class="mui-input-row mui-checkbox">
                                <label>{yun:}$subject_type_name[$v]{/yun} </label>
                                <input name="type" value="{yun:}$v{/yun}" type="checkbox" class="type" data-id="{yun:}$v{/yun}" data-name="{yun:}$subject_type_name[$v]{/yun}" {yun:}if in_array($v,$row.typeid){/yun}checked{yun:}/if{/yun}>
                            </div>
                        </div>
                        {yun:}/foreach{/yun}
                        <a class="yun_wap_info_brief_tit_bc mui-action-back">确定</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="teachhtml" class="mui-page">
    <div class="mui-page-content">
        <div class="mui-scroll-wrapper">
            <div class="mui-scroll">
                <div class="yun_info_fl">
                    <div class="yun_info_fl_c">
                        <div class="yun_wap_addresume_box_nexttit">培训讲师</div>
                        {yun:}foreach item=v from=$teachinfo{/yun}
                        <div class="yun_info_fl_list">
                            <div class="mui-input-row mui-checkbox">
                                <label>{yun:}$v.name{/yun} </label>
                                <input name="teach" value="{yun:}$v{/yun}" type="checkbox" class="teach" data-id="{yun:}$v.id{/yun}" data-name="{yun:}$v.name{/yun}" {yun:}if in_array($v.id,$row.teach){/yun}checked{yun:}/if{/yun}>
                            </div>
                        </div>
                        {yun:}foreachelse{/yun}
                        <div class="yun_info_fl_list">
                            <div class="mui-input-row mui-checkbox">
                                <label>暂无培训讲师</label>
                            </div>
                        </div>
                        {yun:}/foreach{/yun}

                        <a class="yun_wap_info_brief_tit_bc mui-action-back">确定</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    weburl = "{yun:}$config.sy_weburl{/yun}";
    var formData = new FormData(),
        newuploadpic;
</script>

<script src="{yun:}$wap_style{/yun}/js/mui/mui.picker.min.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script src="{yun:}$wap_style{/yun}/js/mui/mui.poppicker.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>

<script src="{yun:}$config.sy_weburl{/yun}/data/plus/city.cache.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script src="{yun:}$wap_style{/yun}/js/mui/mui.view.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script src="{yun:}$wap_style{/yun}/js/category.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script src="{yun:}$wap_style{/yun}/js/publicselect.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>

<script src="{yun:}$wap_style{/yun}/js/umeditor/umeditor.config.js?v={yun:}$config.cachecode{/yun}"></script>
<script src="{yun:}$wap_style{/yun}/js/umeditor/umeditor.min.js?v={yun:}$config.cachecode{/yun}"></script>
<script language="javascript">
    UM.getEditor('contenttext', {
        toolbar: false,
        elementPathEnabled: false,
        wordCount: false,
        autoHeightEnabled: false
    });
    mui.init();
    var viewApi = mui('#app').view({
        defaultPage: '#main'
    });
    
    var view = viewApi.view;
    (function($) {
    	
	    mui('.mui-scroll-wrapper').scroll({
	        scrollY: true, 
	        scrollX: false, 
	        startX: 0, 
	        startY: 0, 
	        indicators: true, 
	        deceleration: 0.0006, 
	        
	    });
        
        var oldBack = $.back;
        $.back = function() {
            if(viewApi.canBack()) { 
                viewApi.back();
            } else { 
                oldBack();
            }
        };
        view.addEventListener('pageShow', function(e) {
            var edittarget = '';
            if(e.detail.page.id == 'contenthtml') {
                edittarget = 'contenttext';
                var contenttext = document.getElementById('content').value;
                if(contenttext) {
	                UM.getEditor(edittarget).setContent(contenttext);
	            }
            }
        });
        view.addEventListener('pageBeforeBack', function(e) {
            var content = '',
                showid = '',
                textid = '';
            if(e.detail.page.id == 'contenthtml') {
                showid = 'contentshow';
                textid = 'content';
                content = UM.getEditor('contenttext').getContent();
                if(content != "") {
	                document.getElementById(showid).innerHTML = content.replace(/<\/?.+?>/g, "").replace(/ /g, "");
	                document.getElementById(textid).value = content;
	            }
            }
            if(e.detail.page.id == 'crowdhtml') {
                document.getElementById('crowdshow').innerHTML = document.getElementById('crowd').value;
            }
            else if(e.detail.page.id == 'superiorityhtml') {
            	document.getElementById('superiorityshow').innerHTML = document.getElementById('superiority').value;
            }
            var checkv = "",
                checkshow = "",
                ltcheck = "",
                vid = "",
                showid = "";
            if(e.detail.page.id == 'typehtml') {
                ltcheck = ".type";
                vid = "type";
                showid = "typeshow";
            } else if(e.detail.page.id == 'teachhtml') {
                ltcheck = ".teach";
                vid = "teach";
                showid = "teachshow";
            }
            if(ltcheck != "") {
                $(ltcheck).each(function(w, checkdata) {
                    if(checkdata.checked == true) {
                        if(checkv == "") {
                            checkv = checkdata.dataset.id;
                        } else {
                            checkv = checkv + "," + checkdata.dataset.id;
                        }
                        if(checkshow == "") {
                            if(checkdata.dataset.name) {
                                checkshow = checkdata.dataset.name;
                            }
                        } else {
                            checkshow = checkshow + "," + checkdata.dataset.name;
                        }
                    }
                });
                if(checkv) {
                    document.getElementById(vid).value = checkv;
                }
                if(checkshow) {
                    document.getElementById(showid).innerText = checkshow;
                }

            }
        });

    })(mui);
    $(document).ready(function() {
		if(document.getElementById('main')){
			document.getElementById('main').addEventListener('touchmove', function (e) { e.preventDefault();}, {passive: false});
		}
		if(document.getElementById('crowdhtml')){
			document.getElementById('crowdhtml').addEventListener('touchmove', function (e) { e.stopPropagation();}, {passive: false});
		}
		if(document.getElementById('superiorityhtml')){
			document.getElementById('superiorityhtml').addEventListener('touchmove', function (e) { e.stopPropagation();}, {passive: false});
		}
		if(document.getElementById('contenthtml')){
			document.getElementById('contenthtml').addEventListener('touchmove', function (e) { e.stopPropagation();}, {passive: false});
		}
	})
    var sidData = [];
    ' {yun:}foreach from=$subject_index item=v{/yun}'
    sidData.push({
        value: '{yun:}$v{/yun}',
        text: '{yun:}$subject_name[$v]{/yun}'
    })
    '{yun:}/foreach{/yun}'
    var prData = [];
    '{yun:}foreach from=$comdata.job_pr item=v{/yun}'
    prData.push({
        value: '{yun:}$v{/yun}',
        text: '{yun:}$comclass_name[$v]{/yun}'
    })
    '{yun:}/foreach{/yun}';
    var munData = [];
    '{yun:}foreach from=$comdata.job_mun item=v{/yun}'
    munData.push({
        value: '{yun:}$v{/yun}',
        text: '{yun:}$comclass_name[$v]{/yun}'
    })
    '{yun:}/foreach{/yun}'
    var nidData = [];
    '{yun:}foreach item=v from=$subject_index{/yun}'
    var nid = [];
    '{yun:}foreach item=vv from=$subject_type[$v]{/yun}'
    nid.push({
        value: '{yun:}$vv{/yun}',
        text: '{yun:}$subject_name[$vv]{/yun}'
    })
    '{yun:}/foreach{/yun}'
    nidData.push({
        value: '{yun:}$v{/yun}',
        text: '{yun:}$subject_name[$v]{/yun}',
        children: nid
    })
    '{yun:}/foreach{/yun}';

    (function() {
        var submitBtn = document.getElementById('infosubmit')
        if(submitBtn) {
            submitBtn.addEventListener('tap', function() {
                var name = $.trim(document.getElementById('name').value),
                    nid = $.trim(document.getElementById('nid').value),
                    tnid = $.trim(document.getElementById('tnid').value),
                    provinceid = $.trim(document.getElementById('provinceid').value),
                    cityid = $.trim(document.getElementById('cityid').value),
                    threecityid = $.trim(document.getElementById('three_cityid').value),
                    address = $.trim(document.getElementById('address').value),
                    price = $.trim(document.getElementById('price').value),
                    hours = $.trim(document.getElementById('hours').value),
                    isprice = $.trim(document.getElementById('isprice').value),
                    moblie = $.trim(document.getElementById('moblie').value),
                    crowd = $.trim(document.getElementById('crowd').value),
                    superiority = $.trim(document.getElementById('superiority').value),
                    content = $.trim(document.getElementById('content').value),
                    type = $.trim(document.getElementById('type').value),
                    teachid = $.trim(document.getElementById('teach').value),
                    preview = $.trim(document.getElementById('preview').value),
                    id = $.trim(document.getElementById('id').value);

                if(name == "") {
                    return mui.toast('课程名称不能为空！');
                    return false;
                }
                if(tnid == "") {
                    return mui.toast('请选择课程类别！');
                    return false;
                }
                if(cityid == "") {
                    return mui.toast('请选择培训地点！');
                    return false;
                }
                if(address == "") {
                    return mui.toast('培训地址不能为空！');
                    return false;
                }
                if(hours == "") {
                    return mui.toast('课程学时不能为空！');
                    return false;
                }
                if(price == "") {
                    return mui.toast('培训费用不能为空！');
                    return false;
                }
                if(isprice < 1) {
                    return mui.toast("请选择收费方式！", 2);
                    return false;
                }
                if(moblie == "") {
                    return mui.toast('报名电话不能为空！');
                    return false;
                }
                if(isjsTell(moblie) == false && isjsMobile(moblie) == false) {
                    return mui.toast('报名电话格式错误！');
                    return false;
                }
                if(crowd == "") {
                    return mui.toast('适合人群不能为空！');
                    return false;
                }
                if(content == '') {
                    return mui.toast('课程介绍不能为空！');
                    return false;
                }
                if(type == '') {
                    return mui.toast('请选择开课类型！');
                    return false;
                }
                formData.append('name', name);
                formData.append('nid', nid);
                formData.append('tnid', tnid);
                formData.append('price', price);
                formData.append('address', address);
                formData.append('provinceid', provinceid);
                formData.append('cityid', cityid);
                formData.append('threecityid', threecityid);
                formData.append('hours', hours);
                formData.append('isprice', isprice);
                formData.append('moblie', moblie);
                formData.append('crowd', crowd);
                formData.append('superiority', superiority);
                formData.append('type', type);
                formData.append('teachid', teachid);
                formData.append('content', content);
                formData.append('preview', preview);
                formData.append('id', id);
                formData.append('submit', 'submit');

                $.ajax({
                    url: "index.php?c=addsubject",
                    type: 'post',
                    data: formData,
                    contentType: false,
                    processData: false,
                    dataType: 'json',
                    success: function(res) {
                        var res = JSON.stringify(res);
                        var data = JSON.parse(res);
                        if(data.url) {
                            layermsg(data.msg, 2, function() {
                                location.href = data.url;
                            });
                        } else {
                            layermsg(data.msg, 2);
                            return false;
                        }
                    }
                })
            }, false)
        }
    })();
</script>
{yun:}include file="$wapstyle/footer.htm"{/yun}